//
//  ShowInfoView.m
//  VwiovAPP
//
//  Created by WXC on 2018/5/25.
//  Copyright © 2018年 WXC. All rights reserved.
//

#import "ShowInfoView.h"
@interface ShowInfoView ()
@property (weak, nonatomic) IBOutlet UILabel *message;
@property (weak, nonatomic) IBOutlet UIView *hud;

@end

@implementation ShowInfoView

+ (void)showMessage:(NSString *)message
{
    ShowInfoView *view = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil]lastObject];
    view.frame = [UIScreen mainScreen].bounds;
    view.message.text = message;
    [[UIApplication sharedApplication].keyWindow addSubview:view];
    
    CGFloat times = 0;
    if (message.length < 10) {
        times = 1;
    }else if (message.length < 20){
        times = 1.5;
    }else if (message.length < 30){
        times = 2;
    }else {
        times = 3;
    }
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(times * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [view removeFromSuperview];
    });

}

- (void)awakeFromNib{
    [super awakeFromNib];
    self.backgroundColor = JYColorA(255, 255, 255, 0.01);
    self.hud.layer.cornerRadius = 5;
}

@end



